home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Inspectors / InspectMe / Thing1.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  119 lines

  1. #import "Thing1.h"
  2. #import "InspectMeDoc.h"
  3. #import "PSWraps.h"
  4. #import <dpsclient/wraps.h>
  5. #import <appkit/NXColorWell.h>
  6.  
  7. @implementation Thing1
  8.  
  9. /* instance methods */
  10.  
  11. - initFrame:(NXRect *)frameRect
  12. {
  13.     [super initFrame:frameRect];
  14.     [self setOpaque:YES];
  15.     selected = NO;
  16.     number = 25;
  17.     size = 10;
  18.     bkgndGray = 0.5;
  19.     bkgndColor = NXConvertGrayToColor(0.5);
  20.     shape = SHAPE_CIRCLES;
  21.     return self;
  22. }
  23.     
  24. - drawSelf:(NXRect *)rects :(int)rectCount
  25. {
  26.     [window disableFlushWindow];
  27.  
  28.     if(!NXEqualColor(bkgndColor, NXConvertGrayToColor(0.5)))
  29.         NXSetColor(bkgndColor);
  30.     else
  31.         PSsetgray(bkgndGray);
  32.     NXRectFill(&rects[0]);
  33.     if (shape == SHAPE_CIRCLES)
  34.         PSthing1(number,size,rects[0].size.width,rects[0].size.height,0);
  35.     else
  36.         PSthing1(number,size,rects[0].size.width,rects[0].size.height,1);
  37.     if(selected)
  38.         PSsetgray(1);
  39.     else
  40.         PSsetgray(0);
  41.     NXFrameRectWithWidth(&rects[0],4);
  42.     [[window reenableFlushWindow] flushWindowIfNeeded];
  43.  
  44.     return self;
  45. }
  46.  
  47. - (BOOL)acceptsFirstMouse
  48. {
  49.     return YES;
  50. }
  51.  
  52. - mouseDown:(NXEvent *)e
  53. {
  54.     [[window delegate] setSelectedObject:self];
  55.     return self;
  56. }
  57.  
  58. - setSelected:(BOOL)yesOrNo
  59. {
  60.     selected = yesOrNo;
  61.     [self display];    
  62.         // note: if the outline is different if selected,
  63.         //  the above should be displayFromOpaqueAncestor:::
  64.     
  65.     return self;
  66. }
  67.  
  68.  
  69. // ---------------------------
  70. //      set/get attributes
  71. // ---------------------------
  72. - setNumber:(int)newNumber;
  73. {
  74.     number = newNumber;
  75.     [self display];
  76.     return self;
  77. }
  78.  
  79. - (int)number {return number; }
  80.  
  81. - setSize:(int)newSize;
  82. {
  83.     size = newSize;
  84.     [self display];
  85.     return self;
  86. }
  87.  
  88. - (int)size {return size; }
  89.  
  90. - setShape:(int)newShape;
  91. {
  92.     shape = newShape;
  93.     [self display];
  94.     return self;
  95. }
  96.  
  97. - (int)shape {return shape; }
  98.  
  99. - setBkgndColor:(NXColor)theColor;
  100. {
  101.     bkgndColor = theColor;
  102.     [self display];
  103.     return self;
  104. }
  105.  
  106. - (NXColor)bkgndColor {return bkgndColor; }
  107.  
  108. - setBkgndGray:(float)theGray;
  109. {
  110.     bkgndGray = theGray;
  111.     bkgndColor = NXConvertGrayToColor(bkgndGray);
  112.     [self display];
  113.     return self;
  114. }
  115.  
  116. - (float)bkgndGray {return bkgndGray; }
  117.  
  118. @end
  119.